# Voting 

library(tidyverse)
library(estimatr)

# California Prop 23 Table 3
df <- read_csv('datasets/ca_prop_23.csv')
df <- df %>% rename(median_income_blk=median_income, pct_college_blk = pct_college)
m1 <- lm_robust(pct_23_no ~ pct_homes_risk + pct_college_blk + median_income_blk + pct_dem, 
                df, clusters=ZCTA5CE10, se_type = 'stata')

# Washington State Prop 723
df <- read_csv('datasets/wa_723.csv')
m2 <- lm_robust(pct_yes_732 ~ pct_homes_risk + median_income_blk + pct_college_blk + pct_dem, 
          df, clusters=ZCTA5CE10, se_type = 'stata')

# Florida Prop 1
df <- read_csv('datasets/fl_prop_1.csv')
m3 <- lm_robust(pct_yes_prop_1 ~ pct_homes_risk + median_income_blk + pct_college_blk + pct_dem, 
                df,clusters = ZCTA5CE10, se_type = 'stata')

texreg::texreg(list(m1, m2, m3), 
               stars = c(0.1,0.05,0.01), 
               include.ci=F,custom.coef.names = c(
                 'Intercept','Susceptibility',
                 'Median Income', 'Pct College', 'Pct Dem Vote'
               ),custom.model.names = c('No on Prop 23 (CA)','Yes on 723 (WA)','Yes Prop 1 (FL)'),
               file = 'tables/table3_behavior_outcomes.tex')

# Placebos Table C22

df <- read_csv('datasets/placebo_props.csv')

m1 <- lm_robust(pct_yes_prop_3 ~ pct_homes_risk + pct_college.y + median_income + pct_dem, df, cluster=ZCTA5CE10)
m2 <- lm_robust(pct_yes_prop_12 ~ pct_homes_risk + pct_college.y + median_income + pct_dem, df, cluster=ZCTA5CE10)
m3 <- lm_robust(pct_yes_prop_2 ~ pct_homes_risk + pct_college.y + median_income + pct_dem, df, cluster=ZCTA5CE10)

texreg::texreg(list(m1, m2, m3), include.ci=F, 
               stars=c(0.10,0.05,0.01),custom.model.names = c(
                 'Prop 3 (Water)', 'Prop 12 (Meat)', 'Prop 2 (Homeless)'
               ), custom.coef.names = c(
                 'Intercept','Susceptibility','Pct College','Median Income',
                 'Pct Dem'
               ),file='tables/appendix_placebo_propositions.tex')
